/*
*定义一个map对象，其元素的键是家族姓氏，而值是存储改家族孩子的名字的vector对象。为这个Map容器输入至少六个条目，通过基于家族姓氏的查询检测你的程序
*查询应该输出该家族所有孩子的名字
*/
#include <iostream>
#include <string>
#include <vector>
#include <map>
using namespace std;

int main()
{
	map<vector<string>, vector<string>> nameMap;
	vector<string> lastNameVec;
	vector<string> nameVec;

	string lastName,name;

	cout << "请输入姓氏：";
	while(cin >> lastName)
	{
		if(lastName == "end")
			break;
		else
			lastNameVec.push_back(lastName);
	}

	cout << "请输入名字：";
	while(cin >> name)
	{
		if(name == "end")
			break;
		else
			nameVec.push_back(name);
	}

	nameMap.insert(make_pair(lastNameVec,nameVec));

	string queryLastName;
	cout << "请输入查询姓氏：";
	cin >> queryLastName;

	map<vector<string>,vector<string>>::iterator iter = nameMap.begin();

	for(vector<string>::const_iterator lastNameIt = iter->first.begin();lastNameIt != iter->first.end();lastNameIt++)
	{
		if(*lastNameIt == queryLastName)
		{
			for(vector<string>::iterator nameIt = iter->second.begin();nameIt != iter->second.end();nameIt++)
			{
				cout << queryLastName << *nameIt << "  ";
			}
			break;
		}
		else
		{
			cout << "无相关信息！";
			break;
		}
	}
	cout << endl;
	system("pause");
	return 0;
}

